<template>
  <view class="date-picker-container">
    <!-- 状态栏 -->
    <view class="status-bar"></view>
    
    <!-- 标题栏 -->
    <view class="header">
      <view class="back-button" @click="goBack">
        <image src="/static/arrow-left.png" mode="aspectFit" class="back-icon"></image>
      </view>
      <text class="title">选择日期</text>
      <view class="placeholder"></view>
    </view>
    
    <!-- 日期选择器 -->
    <picker mode="date" :value="selectedDate" :start="startDate" :end="endDate" @change="onDateChange">
      <view class="picker-view">
        <text class="current-date">{{ selectedDate }}</text>
      </view>
    </picker>
    
    <!-- 确认按钮 -->
    <view class="button-container">
      <button class="confirm-button" @click="confirmDate">确认</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      selectedDate: '',
      startDate: '',
      endDate: ''
    }
  },
  onLoad(options) {
    this.selectedDate = options.date || '';
    this.startDate = options.start || '';
    this.endDate = options.end || '';
  },
  methods: {
    goBack() {
      uni.navigateBack();
    },
    onDateChange(e) {
      this.selectedDate = e.detail.value;
    },
    confirmDate() {
      const eventChannel = this.getOpenerEventChannel();
      eventChannel.emit('onDateSelected', this.selectedDate);
      uni.navigateBack();
    }
  }
}
</script>

<style lang="scss">
.date-picker-container {
  min-height: 100vh;
  background-color: #f8f8f8;
  display: flex;
  flex-direction: column;
}

.status-bar {
  height: 88rpx;
  background-color: #ffffff;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20rpx 32rpx;
  background-color: #ffffff;
  
  .back-button {
    width: 60rpx;
    height: 60rpx;
    display: flex;
    align-items: center;
    .back-icon {
      width: 32rpx;
      height: 32rpx;
    }
  }
  .title {
    font-size: 36rpx;
    font-weight: 500;
    color: #000000;
    flex: 1;
    text-align: center;
  }
  .placeholder {
    width: 60rpx;
  }
}

.picker-view {
  margin: 40rpx;
  padding: 30rpx;
  background-color: #ffffff;
  border-radius: 12rpx;
  display: flex;
  justify-content: center;
  align-items: center;
  
  .current-date {
    font-size: 36rpx;
    color: #333333;
  }
}

.button-container {
  padding: 40rpx;
  
  .confirm-button {
    width: 100%;
    height: 88rpx;
    background-color: #881B20;
    color: #ffffff;
    font-size: 32rpx;
    font-weight: 500;
    border-radius: 44rpx;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>